<?php

class Reg_Raw extends App_Func
{
    function createUser($email, $nick, $password)
    {
        $salt = $this->_createSalt();
        $userInfo = new User_Info();
        $arr = array(
            'email' => $email,
            'nick' => $nick,
            'password' => md5(md5($password) . $salt),
            'salt' => $salt,
        );
        $uid = $userInfo->insert($arr);
        if (empty($uid))
        {
            return false;
        }
        return $uid;
    }

    function updatePassword($uid, $password)
    {
    	$salt = $this->_createSalt();
        $arr = array(
            'password' => md5(md5($password) . $salt),
            'salt' => $salt,
        );
        return $this->user_info->update($uid, $arr);
    }

    private function _createSalt($len = 6)
    {
        $randpwd = '';
        for ($i = 0; $i < $len; $i++)
        {
            $randpwd .= chr(mt_rand(33, 126));
        }
        return $randpwd;
    }
}

?>